<?php
	// 处理添加用户，密码请求
	
	require('../pub.php');
	require(_ROOT.'/db.php');

	$usr = $_REQUEST['userName'];
	$psw = $_REQUEST['psw'];
	$level = $_REQUEST['level'];
	
	if(empty($usr)|| empty($psw))
	{
		echo "用户名或密码为空！";
		echo '<br />';
		echo '<br />';
	}
	//echo $usr.' '.$psw.'<br />';
?>
<?php
	// 密码使用md5加密
	$t_psw = md5($psw);
	
	echo '添加用户名，密码(MD5加密)'.'<br />';
	if (empty($level))
	{
		$sql = "INSERT INTO t_t_user(t_tuser, t_psw) VALUES('$usr', '$t_psw')";		
	}
	else
	{
		$sql = "INSERT INTO t_t_user(t_tuser, t_psw, t_level) VALUES('$usr', '$t_psw', $t_level)";			
	}

	echo $sql.'<br />';
	$data = mysql_query($sql, $conn);
	//while ($arr = mysql_fetch_array($data))
	//{
	//}
	//echo '<br />';
	echo '添加成功'.'<br />';
	
	echo '<br />'.'添加的信息'.'<br />';
	$sql = "SELECT * FROM t_t_user WHERE t_tuser = '$usr'";
	$data = mysql_query($sql, $conn);
	$arr = mysql_fetch_array($data);
	echo 'user \''.$usr.'\' password = '.$arr['t_psw'].' level='.$arr['t_level'];
?>